<template>
  <div>
    <div class="returnTitle">
      <el-page-header @back="goBack" content="添加预警查看详情"></el-page-header>
    </div>
    <div class="center">
      <el-form ref="form" :model="form" label-width="100px" label-position="left" size="small">
        <el-form-item label="学生姓名：">
          {{this.form.real_name}}
        </el-form-item>
        <el-form-item label="上报来源：">
          <el-select v-model="form.source" placeholder="请选择" disabled>
            <el-option v-for="item in options.source" :key="item.id" :label="item.title" :value="item.id"> </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="问题类型：">
          <el-select v-model="form.question_type" placeholder="请选择" disabled>
            <el-option v-for="item in options.crisis" :key="item.id" :label="item.title" :value="item.id"> </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注：">
          <el-input type="textarea" placeholder="请输入内容" v-model="form.add_notes" maxlength="1000" show-word-limit disabled> </el-input>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import {APIEARLYWARNINGSYSTEMLIST, APIEARLYWARNINGGETEARLYWARNINGDETAIL} from '@/common/api.js'
export default {
  props: ['isDetails', 'id'],
  data () {
    return {
      form: {
        real_name: '',
        source: '',
        question_type: '',
        add_notes: ''
      },
      options: {}
    }
  },
  created () {
    this.selectFn()
    this.setDataFn()
  },
  methods: {
    goBack () {
      this.$router.push({path: '/studentCrisis', query: {id: this.$route.query.id}})
    },
    handleClose () {
      this.$emit('noDetails')
    },
    close (type) {
      this.$emit('noDetails', type)
    },
    setDataFn () {
      APIEARLYWARNINGGETEARLYWARNINGDETAIL({
        early_warning_id: this.$route.query.early_warning_id
      }).then((res) => {
        this.form = res.data
      }).catch((err) => {
        this.$message.error(err.msg)
      })
    },
    selectFn () {
      APIEARLYWARNINGSYSTEMLIST().then((res) => {
        this.options = res.data
      }).catch((err) => {
        this.$message.error(err.msg)
      })
    }
  }
}
</script>
